#ifdef _WINDOWS
#include <res/static_resource.h>

#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif // !WIN32_LEAN_AND_MEAN
#include <Windows.h>

namespace primal
{
	namespace res
	{
		bool load_rcdata(utl::filebytes& storage, int rc_id)
		{
			bool load_res{ true };
			auto handle{ GetModuleHandleA(nullptr) };

			load_res &= (handle != nullptr);

			auto fr = FindResourceW(handle, MAKEINTRESOURCEW(rc_id), MAKEINTRESOURCEW(10));

			load_res &= (fr != nullptr);

			if(fr != nullptr)
			{
				auto gr = LoadResource(handle, fr);

				load_res &= (gr != nullptr);

				if(gr != nullptr)
				{
					auto data_ptr = LockResource(gr);
					auto data_size = SizeofResource(handle, fr);

					load_res &= (data_ptr != nullptr && data_size > 0);

					if(data_ptr != nullptr && data_size != 0u)
					{
						storage.resize(data_size);
						memcpy(storage.data(), data_ptr, data_size);
					}
				}
			}

			return load_res;
		}

		constexpr int shader_id_mapping[]
		{
			401,
			501
		};

		bool get_shader_byte(utl::filebytes& storage, SHADER_BYTE_TYPE type)
		{
			return load_rcdata(storage, shader_id_mapping[type]);
		}

		bool get_imgui_font(utl::filebytes& storage)
		{
			return load_rcdata(storage, 201);
		}
	}
}
#endif